﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace OmniKits.Core
{
    public class StacklessExeConfigurationMonitor : ExeConfigurationMonitorBase
    {
#pragma warning disable 1591
        public StacklessExeConfigurationMonitor(ExeConfigurationFileMap configFileMap)
            : base(configFileMap)
        { }

        public event StacklessEventHandler<Configuration> ResetConfigurationEvent;
        public override void ResetConfiguration(Configuration config)
        {
            StacklessEventArgs<Configuration>.Invoke(this, ResetConfigurationEvent, config);
        }

        public event StacklessEventHandler ConfigurationUpdated;
        protected override void OnConfigurationUpdated()
        {
            StacklessEventArgs.Invoke(this, ConfigurationUpdated);
        }

        public class GetConfigurationValidEventArgs : StacklessEventArgsBase<GetConfigurationValidEventArgs>
        {
            public Configuration Config { get; }
            public bool IsValid { get; set; }

            public GetConfigurationValidEventArgs(Configuration config)
            {
                Config = config;
            }
        }
        public event EventHandler<GetConfigurationValidEventArgs> GetConfigurationValidEvent;
        protected override bool GetConfigurationValid(Configuration config)
        {
            var args = new GetConfigurationValidEventArgs(config);
            args.InvokeEventHandler(this, GetConfigurationValidEvent);
            return args.IsValid;
        }
    }
}
